library(flexdashboard)
library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.4.3     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(p8105.datasets)
library(plotly)
## Warning: package 'plotly' was built under R version 4.3.2
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout

Creating a flexdashboard

Plot 1
data("rest_inspec")

df_rest_inspec = 
  rest_inspec |>
  select(
    boro, inspection_date, cuisine_description, score, street, zipcode, grade) |>
  arrange(inspection_date) |>
  mutate(boro = str_to_title(boro)) |>
  drop_na()

df_rest_inspec |>
  plot_ly(y = ~score, color = ~boro, type = "box")
Plot 2
df_rest_inspec |>
  plot_ly(
  x = ~boro, y = ~score, color = ~score, type = "scatter", mode = "markers")